package com.ruoyi.common.utils;

import java.util.Random;

/**
 * 2024-12-30
 * 春秋
 * 随机工具类
 */
public class RandomUtils {

    private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

    public static String generateEasyRandomCode() {
        return generateEasyRandomCode(6);
    }

    public static String generateEasyRandomCode(int codeLength) {
        StringBuilder code = new StringBuilder();
        Random random = new Random();
        // 循环生成随机码
        for (int i = 0; i < codeLength; i++) {
            int index = random.nextInt(CHARACTERS.length());
            code.append(CHARACTERS.charAt(index));
        }
        return code.toString();
    }
}
